<?php
namespace app\api\controller;

/**
 *
 * User: renyixu
 * Date: 2024/11/27
 */
class Pdf extends \TCPDF
{
    private $vehicleName;
    private $vinCode;

    // 构造函数传递车辆名称和 VIN 码
    public function __construct($vehicleName, $vinCode) {
        parent::__construct();
        $this->vehicleName = $vehicleName;
        $this->vinCode = $vinCode;
    }

    // 自定义页眉
    public function Header() {
        $this->SetFont('stsongstdlight', 'B', 10);
        $this->Cell(0, 5, $this->vehicleName, 0, 0, 'L'); // 左侧车辆名称
        $this->Cell(0, 5, $this->vinCode, 0, 1, 'R'); // 右侧 VIN 码
        $this->Ln(2);
        $this->SetLineWidth(0.5);
        $this->SetDrawColor(255, 165, 0); // 橙色分割线
        $this->Line(10, $this->GetY(), 200, $this->GetY());
        $this->Ln(5);
    }

    // 自定义页脚
    public function Footer() {
        $this->SetY(-20); // 页脚位置
        $this->SetLineWidth(0.5);
        $this->SetDrawColor(255, 165, 0); // 橙色分割线
        $this->Line(10, $this->GetY(), 200, $this->GetY());
        $this->SetY(-15);
        $this->SetFont('stsongstdlight', '', 8);
        $this->MultiCell(0, 5, "温馨提示: 验了吗对鉴定车辆进行不解体静态检测，即车辆处于原地静止状态检测，动力系统仅限原地车辆检测，不包含车辆动态行驶性能检测。", 0, 'C');
    }
}